using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerFightActionHandling : MonoSingleton<PlayerFightActionHandling>//已弃用，待删除
{
    public void DoPlayerAction(CharacterActionData data)
    {
        switch (data.actionType)
        {
            case 0://获得格挡
                switch (data.chooseCharacterType)
                {
                    case 0://对友军
                        switch (data.actionRange)
                        {
                            case -1://分裂
                                Debug.LogWarning("分裂还没写");
                                break;
                            case 0://全体
                                foreach (var item in FightController.Instance.playerDataHolder)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        item.TakeDefence(data.actionNum, item);
                                    }
                                }
                                break;
                            case 1://单体
                                if(data.chooseCharacterOrder==-1)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        int order = RandomEngine.Instance.GetRandCombatRewards(0, FightController.Instance.playerDataHolder.Count);
                                        FightController.Instance.playerDataHolder[order].TakeDefence(data.actionNum, FightController.Instance.playerDataHolder[order]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        FightController.Instance.playerDataHolder[data.chooseCharacterOrder].TakeDefence(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder]);
                                    }
                                }
                                break;
                            case 2://前两个
                                for (int i = 0; i < data.actionCount; i++)
                                {
                                    FightController.Instance.playerDataHolder[data.chooseCharacterOrder].TakeDefence(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder]);
                                    if(data.chooseCharacterOrder++<=FightController.Instance.playerDataHolder.Count)
                                    {
                                        FightController.Instance.playerDataHolder[data.chooseCharacterOrder++].TakeDefence(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder++]);
                                    }
                                }
                                break;
                        }
                        break;
                    case 1://对敌人
                        switch (data.actionRange)
                        {
                            case -1://分裂
                                Debug.LogWarning("分裂还没写");
                                break;
                            case 0://全体
                                foreach (var item in FightController.Instance.enemyDataHolder)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        item.TakeDefence(data.actionNum, item);
                                    }
                                }
                                break;
                            case 1://单体
                                if (data.chooseCharacterOrder == -1)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        int order = RandomEngine.Instance.GetRandCombatRewards(0, FightController.Instance.enemyDataHolder.Count);
                                        FightController.Instance.enemyDataHolder[order].TakeDefence(data.actionNum, FightController.Instance.enemyDataHolder[order]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        FightController.Instance.enemyDataHolder[data.chooseCharacterOrder].TakeDefence(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder]);
                                    }
                                }
                                break;
                            case 2://前两个
                                for (int i = 0; i < data.actionCount; i++)
                                {
                                    FightController.Instance.enemyDataHolder[data.chooseCharacterOrder].TakeDefence(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder]);
                                    if (data.chooseCharacterOrder++ <= FightController.Instance.enemyDataHolder.Count)
                                    {
                                        FightController.Instance.enemyDataHolder[data.chooseCharacterOrder++].TakeDefence(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder++]);
                                    }
                                }
                                break;
                        }
                        break;
                }
                break;
            case 1://伤害
                switch (data.chooseCharacterType)
                {
                    case 0://对友军
                        switch (data.actionRange)
                        {
                            case -1://分裂
                                Debug.LogWarning("分裂还没写");
                                break;
                            case 0://全体
                                foreach (var item in FightController.Instance.playerDataHolder)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        item.TakeDamage(data.actionNum, item);
                                    }
                                }
                                break;
                            case 1://单体
                                if (data.chooseCharacterOrder == -1)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        int order = RandomEngine.Instance.GetRandCombatRewards(0, FightController.Instance.playerDataHolder.Count);
                                        FightController.Instance.playerDataHolder[order].TakeDamage(data.actionNum, FightController.Instance.playerDataHolder[order]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        FightController.Instance.playerDataHolder[data.chooseCharacterOrder].TakeDamage(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder]);
                                    }
                                }
                                break;
                            case 2://前两个
                                for (int i = 0; i < data.actionCount; i++)
                                {
                                    FightController.Instance.playerDataHolder[data.chooseCharacterOrder].TakeDamage(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder]);
                                    if (data.chooseCharacterOrder++ <= FightController.Instance.playerDataHolder.Count)
                                    {
                                        FightController.Instance.playerDataHolder[data.chooseCharacterOrder++].TakeDamage(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder++]);
                                    }
                                }
                                break;
                        }
                        break;
                    case 1://对敌人
                        switch (data.actionRange)
                        {
                            case -1://分裂
                                Debug.LogWarning("分裂还没写");
                                break;
                            case 0://全体
                                foreach (var item in FightController.Instance.enemyDataHolder)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        item.TakeDamage(data.actionNum, item);
                                    }
                                }
                                break;
                            case 1://单体
                                if (data.chooseCharacterOrder == -1)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        int order = RandomEngine.Instance.GetRandCombatRewards(0, FightController.Instance.enemyDataHolder.Count);
                                        FightController.Instance.enemyDataHolder[order].TakeDamage(data.actionNum, FightController.Instance.enemyDataHolder[order]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        FightController.Instance.enemyDataHolder[data.chooseCharacterOrder].TakeDamage(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder]);
                                    }
                                }
                                break;
                            case 2://前两个
                                for (int i = 0; i < data.actionCount; i++)
                                {
                                    FightController.Instance.enemyDataHolder[data.chooseCharacterOrder].TakeDamage(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder]);
                                    if (data.chooseCharacterOrder++ <= FightController.Instance.enemyDataHolder.Count)
                                    {
                                        FightController.Instance.enemyDataHolder[data.chooseCharacterOrder++].TakeDamage(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder++]);
                                    }
                                }
                                break;
                        }
                        break;
                }
                break;
            case 2://胆魄
                switch (data.chooseCharacterType)
                {
                    case 0://对友军
                        switch (data.actionRange)
                        {
                            case -1://分裂
                                Debug.LogWarning("分裂还没写");
                                break;
                            case 0://全体
                                foreach (var item in FightController.Instance.playerDataHolder)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        item.TakeCourage(data.actionNum, item);
                                        Debug.LogWarning(data.actionCount);
                                    }
                                }
                                break;
                            case 1://单体
                                if (data.chooseCharacterOrder == -1)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        int order = RandomEngine.Instance.GetRandCombatRewards(0, FightController.Instance.playerDataHolder.Count);
                                        FightController.Instance.playerDataHolder[order].TakeCourage(data.actionNum, FightController.Instance.playerDataHolder[order]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        FightController.Instance.playerDataHolder[data.chooseCharacterOrder].TakeCourage(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder]);
                                    }
                                }
                                break;
                            case 2://前两个
                                for (int i = 0; i < data.actionCount; i++)
                                {
                                    FightController.Instance.playerDataHolder[data.chooseCharacterOrder].TakeCourage(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder]);
                                    if (data.chooseCharacterOrder++ <= FightController.Instance.playerDataHolder.Count)
                                    {
                                        FightController.Instance.playerDataHolder[data.chooseCharacterOrder++].TakeCourage(data.actionNum, FightController.Instance.playerDataHolder[data.chooseCharacterOrder++]);
                                    }
                                }
                                break;
                        }
                        break;
                    case 1://对敌人
                        switch (data.actionRange)
                        {
                            case -1://分裂
                                Debug.LogWarning("分裂还没写");
                                break;
                            case 0://全体
                                foreach (var item in FightController.Instance.enemyDataHolder)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        item.TakeCourage(data.actionNum, item);
                                    }
                                }
                                break;
                            case 1://单体
                                if (data.chooseCharacterOrder == -1)
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        int order = RandomEngine.Instance.GetRandCombatRewards(0, FightController.Instance.enemyDataHolder.Count);
                                        FightController.Instance.enemyDataHolder[order].TakeCourage(data.actionNum, FightController.Instance.enemyDataHolder[order]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < data.actionCount; i++)
                                    {
                                        FightController.Instance.enemyDataHolder[data.chooseCharacterOrder].TakeCourage(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder]);
                                    }
                                }
                                break;
                            case 2://前两个
                                for (int i = 0; i < data.actionCount; i++)
                                {
                                    FightController.Instance.enemyDataHolder[data.chooseCharacterOrder].TakeCourage(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder]);
                                    if (data.chooseCharacterOrder++ <= FightController.Instance.enemyDataHolder.Count)
                                    {
                                        FightController.Instance.enemyDataHolder[data.chooseCharacterOrder++].TakeCourage(data.actionNum, FightController.Instance.enemyDataHolder[data.chooseCharacterOrder++]);
                                    }
                                }
                                break;
                        }
                        break;
                }
                break;
        }
    }
}
